<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="renderer" content="webkit"/>
  <meta name="force-rendering" content="webkit"/>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
  <title>基本设置</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="/bower_components/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="/bower_components/Ionicons/css/ionicons.min.css">
  <link rel="stylesheet" href="/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
  <link rel="stylesheet" href="/dist/css/AdminLTE.min.css">
  <link rel="stylesheet" href="/dist/css/skins/_all-skins.min.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <!--头部-->
  <header id="headerDiv" class="main-header">
    <!--#include  file="/pages/channel/header.html"-->
  </header>

  <!--左侧边栏 -->
  <aside id="sidebarDiv" class="main-sidebar">
    <!--#include  file="/pages/channel/sidebar.html"-->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        基本信息
      </h1>
      <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i> 基本信息</a></li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="nav-tabs-custom">
            <div class="tab-content">
              <div class="active tab-pane" id="basic">
                <form id="dataform" class="form-horizontal">
                  <div class="form-group">
                    <label for="username" class="col-sm-2 control-label">名称：</label>
                    <div class="col-sm-6">
                      <p id="username"></p>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="password" class="col-sm-2 control-label">新密码：</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="password" name="password">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="repassword" class="col-sm-2 control-label">确认密码：</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="repassword">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="email" class="col-sm-2 control-label">电子邮件：</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="email" name="email">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="realname" class="col-sm-2 control-label">真实姓名：</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="realname" name="realname">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="qq" class="col-sm-2 control-label">QQ：</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="qq" name="qq">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="tel" class="col-sm-2 control-label">电话：</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="tel" name="tel" disabled>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="idcard" class="col-sm-2 control-label">身份证：</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="idcard" name="idcard">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="accountname" class="col-sm-2 control-label">收款人姓名：</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="accountname" name="accountname">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="bankbranch" class="col-sm-2 control-label">开户分行：</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="bankbranch" name="bankbranch">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="bankname" class="col-sm-2 control-label">收款银行：</label>
                    <div class="col-sm-6">
                      <select class="form-control" id="bankname" name="bankname">
                        <option value="中国银行">中国银行</option>
                        <option value="农业银行">农业银行</option>
                        <option value="工商银行">工商银行</option>
                        <option value="建设银行">建设银行</option>
                        <option value="交通银行">交通银行</option>
                        <option value="招商银行">招商银行</option>
                        <option value="支付宝">支付宝</option>
                      </select>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="bankaccount" class="col-sm-2 control-label">收款账号：</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="bankaccount" name="bankaccount">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="login_ip" class="col-sm-2 control-label">最近登录：</label>
                    <div class="col-sm-6">
                      <p>IP:&nbsp;<span id="login_ip"></span><br/> 时间:&nbsp;<span  id="login_time"></span></p>
                    </div>
                  </div>
                  <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                      <button  onclick="sumbitForm();" type="button" class="btn btn-danger">保存设置</button>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
  <!--底部-->
  <footer id="footerDiv" class="main-footer">
    <!--#include  file="/pages/admin/footer.html"-->
  </footer>

  <!-- Control Sidebar -->
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/morris.js/morris.min.js"></script>
<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script src="/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<script src="/bower_components/fastclick/lib/fastclick.js"></script>
<script src="/dist/js/adminlte.min.js"></script>
<script src="/dist/js/store.min.js"></script>

<script src="/dist/js/layer/layer.js"></script>

<script>
    $(function () {
        let url="/lmgame/channel/getById";
        $.ajax({
            type : 'POST',
            url : url,
            dataType : "json",
            success: function(data) {
                if(data.code!=0){
                    layer.msg(data.msg);
                    window.location.href = "/index2.html";
                    return;
                }
                $("#username").html(data.data.webmaster.username);
                $("#email").val(data.data.webmaster.email);
                $("#realname").val(data.data.webmaster.realname);
                $("#qq").val(data.data.webmaster.qq);
                $("#tel").val(data.data.webmaster.tel);
                $("#idcard").val(data.data.webmaster.idcard);

                $("#accountname").val(data.data.webmaster.accountname);
                $("#bankbranch").val(data.data.webmaster.bankbranch);
                $("#bankname").val(data.data.webmaster.bankname);
                $("#bankaccount").val(data.data.webmaster.bankaccount);
                $("#province").val(data.data.webmaster.province);
                $("#city").val(data.data.webmaster.city);
                $("#login_ip").html(data.data.webmaster.login_ip);
                $("#login_time").html(data.data.webmaster.login_time);

                $("#count").html(data.data.count);
            },
            error: function(xhr, ts, et) { //XMLHttpRequest, textStatus, errorThrown
                if (xhr.status === 400) {
                    window.location.href = "/pages/channel/login.html";
                }
                if (xhr.status === 403) {
                    window.location.href = "/403.html";
                }
            }
        });
    });

    function sumbitForm() {

        let password = $("#password").val();
        if(password == ''|| password == null){
            divfloat("密码不能为空",210,30);
            return;
        }
        let repassword = $("#repassword").val();
        if(password !== repassword){
            divfloat("两次密码不一致",210,30);
            return;
        }
        let reg = /^[A-Za-z0-9]{6,20}$/;
        if(!reg.test(password)){
            divfloat("密码不符合规则请重新输入(6-20位,包含数字&字母)",210,30);
            return;
        }
        let accountname = $("#accountname").val();
        if(accountname == ''|| accountname == null){
            divfloat("收款人姓名不能为空",210,30);
            return;
        }
        let bankbranch = $("#bankbranch").val();
        if(bankbranch == ''|| bankbranch == null){
            divfloat("开户分行不能为空",210,30);
            return;
        }
        let bankname = $("#bankname").val();
        if(bankname == ''|| bankname == null){
            divfloat("收款银行不能为空",210,30);
            return;
        }
        let bankaccount = $("#bankaccount").val();
        if(bankaccount == ''|| bankaccount == null){
            divfloat("收款账号不能为空",210,30);
            return;
        }
        let url="/lmgame/channel/update";
        $.ajax({
            type : 'POST',
            url : url,
            data : $("#dataform").serialize(),
            dataType : "json",
            success: function(data) {
                if(data.code!=0){
                    layer.msg(data.msg);
                    return;
                }else{
                    layer.msg("修改成功");
                }
            },
            error: function(xhr, ts, et) { //XMLHttpRequest, textStatus, errorThrown
                if (xhr.status === 400) {
                    window.location.href = "/pages/channel/login.html";
                }
                if (xhr.status === 403) {
                    window.location.href = "/403.html";
                }
            }
        });
    }
</script>
</body>
</html>
